<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"      
      xmlns:f="http://xmlns.jcp.org/jsf/core"
      xmlns:h="http://xmlns.jcp.org/jsf/html"      
      xmlns:p="http://primefaces.org/ui" 
      xmlns:component="http://java.sun.com/jsf/composite/component">

    <ui:composition template="/resources/include/template.xhtml">

        <ui:define name="title">

            <h:outputText value="#{bundle.Bambole} - #{bundle.Image}"/>

        </ui:define>

        <ui:define name="body">

            <h:form>

                <ui:include src="/resources/include/menu.xhtml"/>  

                <p:panel header="#{imageController.currentProduct.codeAndNameWithDisabledFormatting} :
                         #{bundle.Image} - 
                         #{bundle.List} - 
                         #{bundle.Records}:
                         #{imageController.pagination.itemsCount > 0 ? imageController.pagination.pageFirstItem + 1 : ''} 
                         #{imageController.pagination.itemsCount > 0 ? '...' : ''}
                         #{imageController.pagination.itemsCount > 0 ? imageController.pagination.pageLastItem + 1 : ''} 
                         #{imageController.pagination.itemsCount > 0 ? '/' : ''}
                         #{imageController.pagination.itemsCount}">

                    <component:toolbar

                        searchButtonDisabled="true"
                        saveButtonDisabled="true"
                        editButtonDisabled="true"
                        deleteButtonDisabled="true"            

                        returnButtonAction="#{imageController.prepareCurrentProductView}"              
                        previousButtonDisabled="#{!imageController.pagination.hasPreviousPage}"
                        previousButtonAction="#{imageController.previous}"       
                        refreshButtonAction="#{imageController.refreshList}"              
                        nextButtonDisabled="#{!imageController.pagination.hasNextPage}"
                        nextButtonAction="#{imageController.next}"
                        createButtonAction="#{imageController.prepareCreate}"

                        /> 

                    <p:spacer/>

                    <p:dataTable id="listDataTable"
                                 var="item"
                                 resizableColumns="true" 
                                 liveResize="true"
                                 value="#{imageController.items}"  
                                 rowKey="#{item.id}" 
                                 rows="#{imageController.pagination.pageSize}" 
                                 rowIndexVar="rowIndex"
                                 emptyMessage="#{bundle.EmptyMessage}">

                        <p:column style="width: 4%; text-align: center">

                            <p:commandLink id="openCommandLink"
                                           action="#{imageController.prepareView}">

                                <img src="#{themeUtil.folderIcon}" height="16" width="16"/>

                                <f:setPropertyActionListener value="#{item}" target="#{imageController.selected}"/>

                                <f:setPropertyActionListener value="#{rowIndex}" target="#{imageController.selectedItemIndex}"/>

                            </p:commandLink>

                            <p:tooltip for="openCommandLink"
                                       value="#{bundle.Open}"/>

                        </p:column> 

                        <p:column headerText="#{bundle.Image}"
                                  style="width: 24%; text-align: center">

                            #{item.enabled ? '' : ' ~ '}

                            <p:graphicImage value="#{imageController.imageFile}"
                                            style="width: 34%" 
                                            cache="false"
                                            rendered="#{item.enabled}">

                                <f:param name="imageId" 
                                         value="#{item.id}"/>

                            </p:graphicImage>                

                        </p:column>                

                        <p:column headerText="#{bundle.Product}"
                                  style="width: 62%">

                            <br/>
                            #{bundle.Code}: #{item.product.codeWithDisabledFormatting}
                            <br/>
                            <br/>
                            #{bundle.Name}: #{item.product.nameWithDisabledFormatting}
                            <br/>
                            <br/>

                        </p:column>           

                    </p:dataTable>          

                </p:panel> 

            </h:form>

        </ui:define>

    </ui:composition>         

</html>
